Skip to content

Conversation

Copy link

Copilot AI commented Oct 11, 2025

Problem

The application was failing to start with a NameError because the current_path variable was referenced on line 195 without being defined:

Traceback (most recent call last):
  File "/media/lamaaz/DL/CV_Studio/main.py", line 241, in <module>
    main()
  File "/media/lamaaz/DL/CV_Studio/main.py", line 195, in main
    node_dir=current_path + '/node',
NameError: name 'current_path' is not defined

Solution

Added the missing variable definition in the main() function before it is used:

# Get the current directory path
current_path = os.path.dirname(os.path.abspath(__file__))

This variable is used to construct the node_dir parameter that gets passed to DpgNodeEditor, specifying the path to the directory containing node modules.

Details

  • The fix uses os.path.dirname(os.path.abspath(__file__)) to get the absolute path of the directory containing main.py
  • This approach is consistent with how paths are constructed elsewhere in the codebase (see line 26-28 for the default settings path)
  • The os module was already imported, so no additional imports were needed
  • The change is minimal and surgical - only 3 lines added (including a comment for clarity)

Testing

  • ✅ Python syntax validation passed
  • ✅ Verified the constructed path points to the correct node directory
  • ✅ No existing tests were affected (no tests exist for main.py)

This fix allows the application to start successfully and proceed past the node editor initialization step.

Original prompt

**** Load Config ********
**** Check Camera Connection ********
[ WARN:0@1.286] global cap_v4l.cpp:913 open VIDEOIO(V4L2:/dev/video1): can't open camera by index
[ERROR:0@1.288] global obsensor_uvc_stream_channel.cpp:158 getStreamChannelGroup Camera index out of range
[ WARN:0@1.296] global cap_v4l.cpp:913 open VIDEOIO(V4L2:/dev/video2): can't open camera by index
[ERROR:0@1.297] global obsensor_uvc_stream_channel.cpp:158 getStreamChannelGroup Camera index out of range
[ WARN:0@1.297] global cap_v4l.cpp:913 open VIDEOIO(V4L2:/dev/video3): can't open camera by index
[ERROR:0@1.298] global obsensor_uvc_stream_channel.cpp:158 getStreamChannelGroup Camera index out of range
**** DearPyGui Setup ********
**** Create NodeEditor ********
Traceback (most recent call last):
File "/media/lamaaz/DL/CV_Studio/main.py", line 241, in
main()
File "/media/lamaaz/DL/CV_Studio/main.py", line 195, in main
node_dir=current_path + '/node',
NameError: name 'current_path' is not defined


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: hackolite <826027+hackolite@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix camera connection errors in initialization Fix NameError: undefined current_path variable in main.py Oct 11, 2025
Copilot AI requested a review from hackolite October 11, 2025 19:14
@hackolite hackolite force-pushed the main branch 2 times, most recently from d9f4029 to f5ce349 Compare November 9, 2025 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants